home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / gnulib / rcs4 / source / rcsbase.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-10  |  14.9 KB  |  438 lines

  1. /*
  2.  *                     RCS common definitions and data structures
  3.  */
  4. #define RCSBASE "$Id: rcsbase.h 5.5 91/02/10 15:59:16 ROOT_DOS Exp $"
  5.  
  6. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  7.    Distributed under license by the Free Software Foundation, Inc.
  8.  
  9. This file is part of RCS.
  10.  
  11. RCS is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 1, or (at your option)
  14. any later version.
  15.  
  16. RCS is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with RCS; see the file COPYING.  If not, write to
  23. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25. Report problems and direct all questions to:
  26.  
  27.     rcs-bugs@cs.purdue.edu
  28.  
  29. */
  30.  
  31.  
  32.  
  33. /*****************************************************************************
  34.  * INSTRUCTIONS:
  35.  * =============
  36.  * The following should be handled in the Makefile:
  37.  *     For USG Unix, define USG; for BSD Unix, don't (see ifdef USG).
  38.  *     For 4.2 bsd, define V4_2BSD; this will replace the routines
  39.  *     getwd() and rename() with the corresponding ones in the C-library.
  40.  *     V4_2BSD also selects different definitions for the macros NCPFN and NCPPN
  41.  *     (max. number of characters per filename, number of characters per path name).
  42.  *     Define STRICT_LOCKING appropriately (see STRICT_LOCKING).
  43.  * The following need be changed for porting to a different machine:
  44.  *     Define SMALLOG for a machine with small memory (like the PDP11).
  45.  *     SMALLOG conserves space for log messages.
  46.  *     Change BYTESIZ if necessary.
  47.  * If you need to change the comment leaders, update the table comtable[]
  48.  * in rcsfnms.c. (This can wait until you know what a comment leader is.)
  49.  *****************************************************************************
  50.  */
  51.  
  52.  
  53. /* $Log:    rcsbase.h $
  54.  * Revision 5.5  91/02/10  15:59:16  ROOT_DOS
  55.  * Remoce difference between DOS & Unix - rcs prefix is RCS/ for all
  56.  * 
  57.  * Revision 5.4  91/02/07  13:52:35  ROOT_DOS
  58.  * Remove nested comment
  59.  * 
  60.  * Revision 5.3  90/07/15  20:28:09  lfk
  61.  * checked in with -k by ROOT_DOS at 91.02.07.11.46.01.
  62.  * 
  63.  * Revision 5.3  90/07/15  20:28:09  lfk
  64.  *  Most major fixes added between rev 5.1 and rev 5.5:
  65.  *       signals fixed so they work on MS-DOS
  66.  *       Added MKS arguments code so argv can be large
  67.  *       added code to handle slashes a'la Unix
  68.  *       added more file extensions to system from MS-DOS
  69.  * 
  70.  * Revision 5.2  90/07/15  11:32:24  ROOT_DOS
  71.  * DOS version of RCS 4.0 checked in for MODS
  72.  * by lfk@athena.mit.edu
  73.  * Also update to MSC 6.0
  74.  * 
  75.  * revision 5.1 koya 90/01/24 06:28:49
  76.  * Initial revision
  77.  * 
  78.  * Revision 4.9  89/05/01  15:17:14  narten
  79.  * botched previous USG fix 
  80.  * 
  81.  * Revision 4.8  89/05/01  14:53:05  narten
  82.  * changed #include <strings.h> -> string.h for USG systems.
  83.  * 
  84.  * Revision 4.7  88/11/08  15:58:45  narten
  85.  * removed defs for functions loaded from libraries
  86.  * 
  87.  * Revision 4.6  88/11/08  12:04:06  narten
  88.  * changes from eggert@sm.unisys.com (Paul Eggert)
  89.  * 
  90.  * Revision 4.6  88/08/09  19:12:36  eggert
  91.  * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
  92.  * 
  93.  * Revision 4.5  87/12/18  17:06:41  narten
  94.  * made removed BSD ifdef, now uses V4_2BSD
  95.  * 
  96.  * Revision 4.4  87/10/18  10:29:49  narten
  97.  * Updating version numbers
  98.  * Changes relative to 1.1 are actually relative to 4.2
  99.  * 
  100.  * Revision 1.3  87/09/24  14:02:25  narten
  101.  * changes for lint
  102.  * 
  103.  * Revision 1.2  87/03/27  14:22:02  jenkins
  104.  * Port to suns
  105.  * 
  106.  * Revision 1.1  84/01/23  14:50:14  kcs
  107.  * Initial revision
  108.  * 
  109.  * Revision 4.2  83/12/20  16:04:20  wft
  110.  * merged 3.6.1.1 and 4.1 (SMALLOG, logsize).
  111.  * moved setting of STRICT_LOCKING to Makefile.
  112.  * changed DOLLAR to UNKN (conflict with KDELIM).
  113.  * 
  114.  * Revision 4.1  83/05/04  09:12:41  wft
  115.  * Added markers Id and RCSfile.
  116.  * Added Dbranch for default branches.
  117.  * 
  118.  * Revision 3.6.1.1  83/12/02  21:56:22  wft
  119.  * Increased logsize, added macro SMALLOG.
  120.  * 
  121.  * Revision 3.6  83/01/15  16:43:28  wft
  122.  * 4.2 prerelease
  123.  * 
  124.  * Revision 3.6  83/01/15  16:43:28  wft
  125.  * Replaced dbm.h with BYTESIZ, fixed definition of rindex().
  126.  * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD.
  127.  * Added macro DELNUMFORM to have uniform format for printing delta text nodes.
  128.  * Added macro DELETE to mark deleted deltas.
  129.  *
  130.  * Revision 3.5  82/12/10  12:16:56  wft
  131.  * Added two forms of DATEFORM, one using %02d, the other %.2d.
  132.  *
  133.  * Revision 3.4  82/12/04  20:01:25  wft
  134.  * added LOCKER, Locker, and USG (redefinition of rindex).
  135.  *
  136.  * Revision 3.3  82/12/03  12:22:04  wft
  137.  * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3,
  138.  * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength
  139.  * using NCPPN. Changed putc() to abort on write error.
  140.  *
  141.  * Revision 3.2  82/10/18  15:03:52  wft
  142.  * added macro STRICT_LOCKING, removed RCSUMASK.
  143.  * renamed JOINFILE[1,2] to JOINFIL[1,2].
  144.  *
  145.  * Revision 3.1  82/10/11  19:41:17  wft
  146.  * removed NBPW, NBPC, NCPW.
  147.  * added typdef int void to aid compiling
  148.  */
  149.  
  150.  
  151.  
  152. #include <stdio.h>
  153. #ifdef MKS
  154. #define STREQ(a,b)    ( strcmp( (a), (b) ) == 0 )
  155. #endif
  156. #ifdef USG
  157. #include <string.h>
  158. #else
  159. #include <strings.h>
  160. #endif
  161. #undef putc         /* will be redefined */
  162.  
  163.  
  164. #ifdef USG
  165. #       define rindex    strrchr
  166. #       define DATEFORM  "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d"
  167. #else
  168. #       define DATEFORM  "%02d.%02d.%02d.%02d.%02d.%02d"
  169. #endif
  170. /* Make sure one of %02d or %.2d prints a number with a field width 2, with
  171.  * leading zeroes. For example, 0, 1, and 22 must be printed as 00, 01, and
  172.  * 22. Otherwise, there will be problems with the dates.
  173.  */
  174.  
  175. #define PRINTDATE(file,date) fprintf(file,"%.2s/%.2s/%.2s",date,date+3,date+6)
  176. #define PRINTTIME(file,date) fprintf(file,"%.2s:%.2s:%.2s",date+9,date+12,date+15)
  177. /* print RCS format date and time in nice format from a string              */
  178.  
  179. /*
  180.  * Parameters
  181.  */
  182. #define BYTESIZ             8 /* number of bits in a byte                   */
  183.  
  184. #if 0
  185. #define STRICT_LOCKING    0 /* 0 sets the default locking to non-strict;  */
  186.                               /* used in experimental environments.         */
  187.                               /* 1 sets the default locking to strict;      */
  188.                               /* used in production environments.           */
  189. #endif                  /* STRICT_LOCKING is set in the Makefile!     */
  190. #ifndef hshsize
  191. #define hshsize           239 /* hashtable size; MUST be prime and -1 mod 4 */
  192.                               /* other choices: 547 or 719                  */
  193. #endif
  194.  
  195. #define strtsize (hshsize * 50) /* string table size                        */
  196. #ifdef SMALLOG
  197. #  define logsize         1024 /* max. size of log message for pdp11        */
  198. #else
  199. #  define logsize         4096 /* max. size of log message for others       */
  200. #endif
  201. #define revlength          30 /* max. length of revision numbers            */
  202. #define datelength         20 /* length of a date in RCS format             */
  203. #define joinlength         20 /* number of joined revisions permitted       */
  204. #define RCSDIR         "RCS/" /* subdirectory for RCS files                 */
  205. #ifdef MSDOS        /* Added by $Author: ROOT_DOS $ */
  206. #define RCSSUF            '\0' /* suffix for RCS files                       */
  207. #define RCSSEP            '\0' /* separator for RCSSUF                       */
  208. #else
  209. #define RCSSUF            'v' /* suffix for RCS files                       */
  210. #define RCSSEP            ',' /* separator for RCSSUF                       */
  211. #endif /* MSDOS */
  212. #define KDELIM            '$' /* delimiter for keywords                     */
  213. #define VDELIM            ':' /* separates keywords from values             */
  214. #define DEFAULTSTATE    "Exp" /* default state of revisions                 */
  215. #ifdef V4_2BSD
  216. #  define NCPFN           256 /* number of characters per filename          */
  217. #  define NCPPN          1024 /* number of characters per pathname          */
  218. #else
  219. #ifdef MSDOS        /* Added by $Author: ROOT_DOS $ */
  220. #  define NCPFN            13 /* number of characters per filename          */
  221. #  define NCPPN              66 /* number of characters per pathname          */
  222. #else
  223. #  define NCPFN            14 /* number of characters per filename          */
  224. #  define NCPPN       6*NCPFN /* number of characters per pathname          */
  225. #endif /* MSDOS */
  226. #endif
  227. #define keylength          20 /* buffer length for expansion keywords       */
  228. #define keyvallength NCPPN+revlength+datelength+60
  229.                               /* buffer length for keyword expansion        */
  230.  
  231.  
  232.  
  233. #define true     1
  234. #define false    0
  235. #define nil      0
  236. #define elsif    else if
  237. #define elif     else if
  238.  
  239.  
  240. /* temporary file names */
  241.  
  242. #ifdef MSDOS            /* Added by $Author: ROOT_DOS $ */
  243. #define NEWRCSFILE  "nwXXXXXX"
  244. #define DIFFILE     "ciXXXXXX"
  245. #define TMPFILE1    "t1XXXXXX"
  246. #define TMPFILE2    "t2XXXXXX"
  247. #define TMPFILE3    "t3XXXXXX"
  248. #define JOINFIL2    "j2XXXXXX"
  249. #define JOINFIL3    "j3XXXXXX"
  250. #else
  251. #define NEWRCSFILE  ",RCSnewXXXXXX"
  252. #define DIFFILE     ",RCSciXXXXXX"
  253. #define TMPFILE1    ",RCSt1XXXXXX"
  254. #define TMPFILE2    ",RCSt2XXXXXX"
  255. #define TMPFILE3    ",RCSt3XXXXXX"
  256. #define JOINFIL2    ",RCSj2XXXXXX"
  257. #define JOINFIL3    ",RCSj3XXXXXX"
  258. #endif /* MSDOS */
  259.  
  260.  
  261. #define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):fflsbuf((unsigned)(x),p))
  262. /* This version of putc prints a char, but aborts on write error            */
  263.  
  264. #define GETC(in,out,echo) (c=getc(in), echo?putc(c,out):c)
  265. /* GETC modifies a local variable c; a kludge, but smaller and faster.      */
  266. /* GETC writes a del-character (octal 177) on end of file                   */
  267.  
  268. #ifdef MSDOS
  269. #define WORKMODE(RCSmode) (RCSmode & ~S_IWRITE)|((lockflag||!StrictLocks)? ( S_IWRITE | S_IREAD ) : 0000 )
  270. #else
  271. #define WORKMODE(RCSmode) (RCSmode&~0222)|((lockflag||!StrictLocks)?0600:0000)
  272. #endif /* MSDOS */
  273. /* computes mode of working file: same as RCSmode, but write permission     */
  274. /* determined by lockflag and StrictLocks.                                  */
  275.  
  276.  
  277. /* character classes and token codes */
  278. enum tokens {
  279. /* char classes*/  DIGIT, IDCHAR, NEWLN, LETTER, PERIOD, SBEGIN, SPACE, UNKN,
  280. /* tokens */       COLON, DATE, EOFILE, ID, KEYW, NUM, SEMI, STRING,
  281. };
  282.  
  283. #define AT      SBEGIN  /* class SBEGIN (string begin) is returned by lex. anal. */
  284. #define SDELIM  '@'     /* the actual character is needed for string handling*/
  285. /* these must be changed consistently, for instance to:
  286.  * #define DQUOTE       SBEGIN
  287.  * #define SDELIM       '"'
  288.  * #define AT           IDCHAR
  289.  * there should be no overlap among SDELIM, KDELIM, and VDELIM
  290.  */
  291.  
  292. /* other characters */
  293.  
  294. #define ACCENT   IDCHAR
  295. #define AMPER    IDCHAR
  296. #define BACKSL   IDCHAR
  297. #define BAR      IDCHAR
  298. #define COMMA    UNKN
  299. #define DIVIDE   IDCHAR
  300. #define DOLLAR   UNKN                /* overlap with KDELIM */
  301. #define DQUOTE   IDCHAR
  302. #define EQUAL    IDCHAR
  303. #define EXCLA    IDCHAR
  304. #define GREAT    IDCHAR
  305. #define HASH     IDCHAR
  306. #define INSERT   UNKN
  307. #define LBRACE   IDCHAR
  308. #define LBRACK   IDCHAR
  309. #define LESS     IDCHAR
  310. #define LPARN    IDCHAR
  311. #define MINUS    IDCHAR
  312. #define PERCNT   IDCHAR
  313. #define PLUS     IDCHAR
  314. #define QUEST    IDCHAR
  315. #define RBRACE   IDCHAR
  316. #define RBRACK   IDCHAR
  317. #define RPARN    IDCHAR
  318. #define SQUOTE   IDCHAR
  319. #define TILDE    IDCHAR
  320. #define TIMES    IDCHAR
  321. #define UNDER    IDCHAR
  322. #define UPARR    IDCHAR
  323.  
  324.  
  325.  
  326.  
  327. /***************************************
  328.  * Data structures for the symbol table
  329.  ***************************************/
  330.  
  331.  
  332. /* Hash table entry */
  333. struct hshentry {
  334.         char              * num;      /* pointer to revision number (ASCIZ) */
  335.         char              * date;     /* pointer to date of checking        */
  336.         char              * author;   /* login of person checking in        */
  337.         char              * lockedby; /* who locks the revision             */
  338.         char              * log;      /* log message requested at checkin   */
  339.         char              * state;    /* state of revision (Exp by default) */
  340.         struct branchhead * branches; /* list of first revisions on branches*/
  341.         struct hshentry   * next;     /* next revision on same branch       */
  342.         int                 insertlns;/* lines inserted (computed by rlog)  */
  343.         int                 deletelns;/* lines deleted  (computed by rlog)  */
  344.         char                selector; /* marks entry for selection/deletion */
  345. };
  346.  
  347. /* list element for branch lists */
  348. struct branchhead {
  349.         struct hshentry   * hsh;
  350.         struct branchhead * nextbranch;
  351. };
  352.  
  353. /* accesslist element */
  354. struct access {
  355.         char              * login;
  356.         struct access     * nextaccess;
  357. };
  358.  
  359. /* list element for locks  */
  360. struct lock {
  361.         char              * login;
  362.         struct hshentry   * delta;
  363.         struct lock       * nextlock;
  364. };
  365.  
  366. /* list element for symbolic names */
  367. struct assoc {
  368.         char              * symbol;
  369.         struct hshentry   * delta;
  370.         struct assoc      * nextassoc;
  371. };
  372.  
  373.  
  374. /* common variables (getadmin and getdelta())*/
  375. extern char            * Comment;
  376. extern struct access   * AccessList;
  377. extern struct assoc    * Symbols;
  378. extern struct lock     * Locks;
  379. extern struct hshentry * Head;
  380. extern struct hshentry * Dbranch;
  381. extern int               StrictLocks;
  382. extern int               TotalDeltas;
  383. #ifndef lint
  384. static char copyright[]="Copyright (C) 1982 by Walter F. Tichy";
  385. #endif
  386.  
  387. /* common variables (lexical analyzer)*/
  388. extern enum tokens map[];
  389. #define ctab (&map[1])
  390. extern enum tokens       nexttok;
  391. extern int               hshenter;
  392. extern char            * NextString;
  393. extern char            * cmdid;
  394.  
  395. #if defined(USG) || defined(V4_2BSD)
  396. #define VOID    (void)
  397. #else
  398. typedef int void;
  399. #define VOID
  400. #endif
  401.  
  402. /* common routines */
  403. extern char *talloc();
  404. extern int serror();
  405. extern int faterror();
  406. extern int fatserror();
  407. extern void ignoreints();
  408. extern void catchints();
  409. extern void restoreints();
  410.  
  411. #ifdef USG
  412. extern int sprintf();
  413. #endif
  414.  
  415. /*
  416.  * Markers for keyword expansion (used in co and ident)
  417.  */
  418. #define AUTHOR          "Author"
  419. #define DATE            "Date"
  420. #define HEADER          "Header"
  421. #define IDH             "Id"
  422. #define LOCKER          "Locker"
  423. #define LOG             "Log"
  424. #define RCSFILE         "RCSfile"
  425. #define REVISION        "Revision"
  426. #define SOURCE          "Source"
  427. #define STATE           "State"
  428.  
  429. enum markers { Nomatch, Author, Date, Header, Id,
  430.            Locker, Log, RCSfile, Revision, Source, State };
  431.  
  432. #define DELNUMFORM      "\n\n%s\n%s\n"
  433. /* used by putdtext and scanlogtext */
  434. #define DELETE          'D'
  435. /* set by rcs -o and used by puttree() in rcssyn */
  436.  
  437.  
  438.